//
//  main.m
//  08 - New features
//
//  Created by 韩旭 on 16/7/13.
//  Copyright © 2016年 基础. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Truck.h"
#import "NSArray+NSArray.h"
#import "Man.h"
#import "Person.h"
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        
#pragma mark -
#if 0
        {
            //            iOS9新特性三块的深入理解, 创建几个类, 熟悉写法(提交练习成果)
            //
            //            预习UI内容
            Person *person = [[Person alloc] init];
            person.name = nil;
            person.string = nil;
            [person setArray:nil];
            
        }
#endif
#pragma mark - 泛型
#if 0
        {
            
            Truck<Person *> *truckPer = [[Truck alloc] init];
            Truck<Man *> *truckMan = [[Truck alloc] init];
            Person *per = [[Person alloc] init];
            Man *man = [[Man alloc] init];
            [truckPer addObject:per];
            [truckMan addObject:man];
            [truckPer addObject:man];
            [truckMan addObject:per];
            
            
            Truck *truck = [[Truck alloc] init];
            Truck<NSArray *> *truck1 = [[Truck alloc] init];
            Truck<NSMutableArray *> *truck2 = [[Truck alloc] init];
            
            truck = nil;
            truck = truck1;
            truck = truck2;
            truck2 = truck1;
            truck2 = truck;
            truck1 = truck;
            truck1 = truck2;
            //            大类型 （任意类型） 可以给有泛型的赋值
            //            也可以有泛型的指针
            //            __covariant 协变性 子类在给父类赋值时，自动强转
            //            Truck<NSArray *> 与 Truck<NSMutableArray>
            truck1 = truck2;
            //            __contravariant 逆变性 父类给子类赋值 ， 自动强转（不知道应用到何处）
            truck2 = truck1;
            
        }
#endif
#pragma mark - 3__kindof
#if 1
        {
            //            3 kindof
            //            加__kindof修饰后，返回的其子类都可以接受这个返回值
            Truck *truck = [[Truck alloc] init];
            NSMutableArray *arr = [truck retainArray];
            NSLog(@"%@", arr);
            NSArray *arr1 = [NSArray array];
            NSLog(@"%@", arr1);
        }
#endif
#pragma mark - //iOS 类扩展方式的复习 1> 给NSMutableArray添加convert方法，实现数组倒序。
#if 1
        {
            
            NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", nil];
            NSArray *arrAll = [arr convertWithArray];
            NSLog(@"%@", arrAll);
            
        }
#endif
        
    }
    return 0;
}
